Fix: stage bgemm's C accumulator to the device (host_build_graph) - #1488
Conversation
|
Warning Review limit reached
Next review available in: 20 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Fixes hw-native-sys#1483 `tests/st/a2a3/host_build_graph/bgemm` declared its `C` argument `D.OUT`, but the task graph read-modify-writes it: `p_add.add_inout(c_view)` feeds `kernel_tile_add`, whose first `k` iteration `TLOAD`s `C` before any task has written it. The runtime stages only IN/INOUT tensors host->device (`runtime_maker.cpp`, "pure write-only OUTPUT buffers are never read by the kernel"), and since hw-native-sys#1365 it no longer zero-fills OUT buffers either. So `C` accumulated onto whatever the device allocation happened to hold. On sim that allocation is a plain `malloc` block on a process-lifetime worker: fresh zeros when the case runs alone, a previous case's bytes in a full-suite run — hence a golden mismatch of 1e25-1e36 that reproduced only under the full suite. Same class as hw-native-sys#1449. Declare `C` INOUT, matching the two sibling bgemm variants (`examples/a5/tensormap_and_ringbuffer/bgemm`, `examples/a2a3/tensormap_and_ringbuffer/benchmark_bgemm`), which already tag their accumulator that way. Seed `C` with a non-zero base (0.25) so the staging is load-bearing and the case is deterministic: golden is now `C_init + A @ B`, which a zeroed or unstaged device buffer cannot match. Without the signature fix this fails every run instead of one in two or three — verified, it reproduces the reported 1e35 magnitude on the first attempt. Drop the `pytest.mark.skip` that quarantined the case: the underlying defect is fixed, so the case runs in CI again. Verified: bgemm passes 3/3 in isolation on a2a3sim and onboard on a2a3; the full `pytest examples tests/st --platform a2a3sim` suite is green 3/3 runs. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
0cae19b to
b7d0fd8
Compare
Summary
Fixes #1483 —
tests/st/a2a3/host_build_graph/bgemmintermittently failed its golden compare withmax_diffof 1e25–1e36, but only in full-suite sim runs, never in isolation.Root cause
Cis declaredD.OUTin the orchestration signature, but the task graph read-modify-writes it:p_add.add_inout(c_view)feedskernel_tile_add, whose firstkiterationTLOADsCbefore any task has written it.The runtime stages only IN/INOUT tensors host→device (
src/a2a3/runtime/host_build_graph/host/runtime_maker.cpp— "pure write-only OUTPUT buffers are never read by the kernel"), and since #1365 (affb4612) it no longer zero-fills OUT buffers either. SoCaccumulated onto whatever the device allocation happened to hold. On sim that allocation is a plainmallocblock on a process-lifetime worker (memory_allocator.cpp): fresh zeros when the case runs alone, a previous case's bytes under the full suite. Same class as #1449.Both sibling bgemm variants already tag their accumulator correctly —
examples/a5/tensormap_and_ringbuffer/bgemmandexamples/a2a3/tensormap_and_ringbuffer/benchmark_bgemmuseD.INOUT. The hbg ST was the only one mislabelling it.Fix
signature:[D.IN, D.IN, D.OUT]→[D.IN, D.IN, D.INOUT].Cwith a non-zero base (0.25) and dropC[:] = 0.0fromcompute_golden, so golden isC_init + A @ B. This makes the staging load-bearing: a zeroed or unstaged device buffer can no longer match, so a future regression fails deterministically instead of hiding behind a happens-to-be-zero allocation.pytest.mark.skipthat quarantined the case — the defect it tracked is fixed, so the case runs in CI again.Verification
D.OUT, the case fails on the first attempt withmax_diff=8.0e+35— the reported signature, now deterministic rather than one run in two or three.a2a3simand onboard ona2a3undertask-submit.pytest examples tests/st --platform a2a3sim --device 0-15 --pto-session-timeout 600 --require-pto-isa— green on 5/5 consecutive runs, 3 before and 2 after the rebase onto23de96e0(issue reported ~1-in-2-to-3 failures).pre-commitclean on all three changed files.Scope
I surveyed every other
add_inoutorchestration undertests/st/a2a3/host_build_graph/:available_aicore_countsandpredicated_dispatchalready declare their tensors INOUT, anddump_args/matmul/vector_examplecover their OUT tensor with anadd_outputbefore any read. bgemm was the only offender, so no other test is touched.🤖 Generated with Claude Code